<template>
  <!-- 设备台账 -->
  <Layout>
      <Form ref="form1" :label-width="120">
            <Row  v-show="!switchFlag" class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="设备名称：">
                        <Input class="query-form-el" type="text" v-model="eqCName"></Input>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="所属单位：">
                        <orgCascaderDom class="query-form-el" ref="orgInfoQuery" @setOrgInfo="setBelongOrgIdQuery"
                         @setOrgname="setBelongOrgNameQuery"   :currentOrgId = "belongOrgIdQuery"
                                :currentOrgName = "belongOrgNameQuery"  :rootAffordIf="true" :orgTree = "true">
                        </orgCascaderDom>
                    </FormItem>
                </Col>
                <Col span="8" >
                    <Button @click="reset" class="ivu-btn-reset"  >重置</Button>
                    <Button type="primary" class="ivu-btn-query"   icon="md-search"  @click="queryAccount">查询</Button>
                </Col>
            </Row>
            <Row  v-show="switchFlag" class="query-form" style="padding-top: 15px">
                <Col span="8">
                    <FormItem label="设备名称：">
                        <Input class="query-form-el" type="text" v-model="eqCName"></Input>
                    </FormItem>
                </Col>
                <Col span="8">
                    <FormItem label="所属单位：">
                        <orgCascaderDom class="query-form-el" ref="orgInfoQuery" @setOrgInfo="setBelongOrgIdQuery"
                         @setOrgname="setBelongOrgNameQuery"   :currentOrgId = "belongOrgIdQuery"
                                :currentOrgName = "belongOrgNameQuery"  :rootAffordIf="true" :orgTree = "true">
                        </orgCascaderDom>
                    </FormItem>
                </Col>
            </Row>
            <Row v-show="switchFlag" class="query-form">
                <Col span="24">
                    <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text"  >收起∧</Button>
                    <Button @click="reset" class="ivu-btn-reset"   >重置</Button>
                    <Button type="primary" class="ivu-btn-query"   icon="md-search" @click="queryAccount">查询</Button>
                </Col>
            </Row>
            <Row class="query-form">
                <Col span="24">
                    <Button size="large"  class="ivu-btn-add" icon="md-add"  @click="addEquipment">新增</Button>
                    <!--<Button size="large"  class="ivu-btn-delete" icon="md-trash" @click="batDelete">删除</Button>-->
                </Col>
            </Row>
        </Form>

      <!-- 响应结果内容展示 -->
      <Table ref='table' :height="tableHeight" :loading="loading" size="small" :row-class-name="rowClassName" no-data-text="没有查询到相关数据!"
           stripe border :columns="columns1"  @on-selection-change = 'getSelectRows' :data="resultData">
      </Table>
    <Row style="margin-right:10px;">
        <Col span="24" >
                <Page style="float: right"
                :total="dataCount"
                :page-size="pageSize"
                @on-change="changepage"
                 @on-page-size-change="nowPageSize"
                 :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
        </Col>
    </Row>
    <Modal  title="设备台账" :transfer=false v-model="model1"  :width=600>
        <Row>
            <Col span="24">
                <Form ref="formCustom" :model="formCustom" :rules="ruleValidate"  label-position="top">
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="设备名称" prop="eqCName">
                                <Input type="text" v-model="formCustom.eqCName"></Input>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="规格型号" prop="specId">
                                <Select v-model="formCustom.specId" >
                                    <Option v-for="item in specIds" :value="item.specId" :label="item.specModels">{{ item.specModels }}</Option>
                                </Select>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="制造单位" prop="makeOrgName">
                                <Input type="text" v-model="formCustom.makeOrgName"></Input>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="检验周期" prop="inspectionPeriod">
                              <!--  <Input type="text" v-model="formCustom.inspectionPeriod"></Input>-->
                                <Select  v-model="formCustom.inspectionPeriod">
                                    <Option v-for="item in inspectionPeriodList" :value="item.codingCodeId" :label="item.codingName">
                                        {{item.codingName}}
                                    </Option>
                                </Select>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="产品合格证号" prop="productCertificateNo">
                                <Input type="text" v-model="formCustom.productCertificateNo"></Input>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="使用许可证号" prop="useLicenseNo">
                                <Input type="text" v-model="formCustom.useLicenseNo"></Input>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11" >
                            <FormItem label="设备注册证号" prop="registrationCertificateNo">
                                <Input type="text" v-model="formCustom.registrationCertificateNo"></Input>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="投产日期" prop="commissionDate">
                                <DatePicker type="date"   v-model="formCustom.commissionDate" class="query-form-el"
                                format="yyyy-MM-dd"  placeholder="请选择" ></DatePicker>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="定检日期" prop="fixedInspectionDate">
                                <DatePicker type="date"   v-model="formCustom.fixedInspectionDate" class="query-form-el"
                                format="yyyy-MM-dd"  placeholder="请选择" ></DatePicker>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="检验结果" prop="inspectionResult">
                                <Input type="text" v-model="formCustom.inspectionResult"></Input>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="所属单位" prop="belongOrgId">
                                <orgCascaderDom class="query-form-el" ref="orgInfo" @setOrgInfo="setBelongOrgId"
                                  @setOrgname="setBelongOrgName"   :currentOrgId = "belongOrgId"
                                :currentOrgName = "belongOrgName"  :rootAffordIf="true" :orgTree = "true"  ></orgCascaderDom>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="安装位置" prop="coordSite">
                                <Input type="text" v-model="formCustom.coordSite"></Input>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="使用状况" prop="useStatus">
                                <Input type="text" v-model="formCustom.useStatus"></Input>
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="备注" prop="notes">
                                <Input type="text" v-model="formCustom.notes"></Input>
                            </FormItem>
                        </Col>
                    </Row>
                   <!-- <Row type="flex" justify="center" class="code-row-bg">
                        <Col span="23" >
                            <FormItem>
                                <Button type="primary"  class='ivu-btn-save' :loading="buttonLoading" @click="submit()" >确定</Button>
                                <Button type="primary"  class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
                            </FormItem>
                        </Col>
                    </Row>-->
                </Form>
            </Col>
        </Row>
        <div slot="footer">
            <Button type="primary"  class='ivu-btn-save' :loading="buttonLoading" @click="submit()" >确定</Button>
            <Button type="primary"  class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
        </div>
    </Modal>

    <Modal title="设备台账" class="modal-view-detail" :transfer=false v-model="model2"  :width=600>
        <Row>
            <Col span="24">
                <Form  :model="showData" :label-width="120" >
                  <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="设备中文名称">
                                {{showData.eqCName}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="规格型号">
                                {{showData.specModels}}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="制造单位">
                                {{showData.makeOrgName}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="检验周期">
                                {{showData.inspectionPeriodName}}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="产品合格证号">
                                {{showData.productCertificateNo}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="使用许可证号">
                                {{showData.useLicenseNo}}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11" >
                            <FormItem label="设备注册证号">
                                {{showData.registrationCertificateNo}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="投产日期">
                                {{showData.commissionDate}}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="定检日期">
                                {{showData.fixedInspectionDate}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="检验结果">
                                {{showData.inspectionResult}}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="所属单位">
                                {{showData.belongOrgName}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="安装位置">
                                {{showData.coordSite}}
                            </FormItem>
                        </Col>
                    </Row>
                    <Row type="flex" justify="space-around" class="code-row-bg">
                        <Col span="11">
                            <FormItem label="使用状况">
                                {{showData.useStatus}}
                            </FormItem>
                        </Col>
                        <Col span="11">
                            <FormItem label="备注">
                                {{showData.notes}}
                            </FormItem>
                        </Col>
                    </Row>
                    <!--<Row>
                        <Col span="23" >
                            <FormItem>
                                <Button class='ivu-btn-save' @click="model2=false">关闭</Button>
                            </FormItem>
                        </Col>
                    </Row>-->
                </Form>
            </Col>
        </Row>
        <div slot="footer">
            <Button class='ivu-btn-save' @click="model2=false">关闭</Button>
        </div>
    </Modal>

  </layout>

</template>

<script>
    import {
        Api
    } from "../../../../api/index.js"
    import orgCascaderDom from '../util/cascader-dom'
    // import orgCascaderDom from '../../../../components/cascader-dom.vue';
    import {sessionStorage} from '@/common/cacheUtils.js';

    export default {
        components: {
            orgCascaderDom
        },
        data() {
            return {
                switchFlag: false,
                formCustom: {},
                inspectionPeriodList:[],
                specIds: [],
                tableHeight: 220,loading: false,
                styleArr: [{
                    lineHeight: '30px',
                    width: '220px'
                }],
                divStyle: {
                    marginTop: '20px'
                },
                btn: {
                    width: '80px',
                    height: '36px',
                    color: '#fff',
                    borderRadius: '4px',
                    border: '1px solid #dcdee2',
                    textAlign: 'center',
                    verticalAlign: 'middle',
                    marginLeft: '10px',
                },
                pageSizeArray: [10, 20, 50],
                dataCount: 0,
                pageSize: 10,
                currentPage: 1,
                columns1: [
                    {
                        title: "序号",
                        width: 80,
                        align: "center",
                        fixed:'left',
                        render: (h, params) => {
                            return h('span', params.index + (this.currentPage - 1) * this.pageSize + 1);
                        }
                    },
                    // {
                    //     type: 'selection',
                    //     title: '序号',
                    //     width: 80,
                    //     align: 'center',
                    // },
                    {
                        title: '设备名称',
                        align: 'center',
                        width:100,
                        key: 'eqCName'
                    },
                    {
                        title: '规格型号',
                        align: 'center',
                        width:100,
                        key: 'specModels'
                    },
                    {
                        title: '检验周期',
                        align: 'center',
                        width:150,
                        key: 'inspectionPeriodName'
                    },
                    {
                        title: '产品合格证号',
                        align: 'center',
                        width:150,
                        key: 'productCertificateNo'
                    },
                    {
                        title: '使用许可证号',
                        align: 'center',
                        width:150,
                        key: 'useLicenseNo'
                    },
                    {
                        title: '设备注册证号',
                        align: 'center',
                        width:150,
                        key: 'registrationCertificateNo'
                    },
                    {
                        title: '投产日期',
                        align: 'center',
                        width:100,
                        key: 'commissionDate',
                        render:(h,params)=>{
                            return h('div',[
                                (this.formatDate(new Date(params.row.commissionDate), 'yyyy-MM-dd'))
                            ]);
                        }
                    },
                    {
                        title: '定检日期',
                        align: 'center',
                        width:100,
                        key: 'fixedInspectionDate',
                        render:(h,params)=>{
                            return h('div',[
                                (this.formatDate(new Date(params.row.fixedInspectionDate), 'yyyy-MM-dd'))
                            ]);
                        }
                    },
                    {
                        title: '检验结果',
                        align: 'center',
                        width:100,
                        key: 'inspectionResult'
                    },
                    {
                        title: '制造单位',
                        width:200,
                        align: 'center',
                        ellipsis:'true',
                        key: 'makeOrgName'
                    },
                    {
                        title: '所属单位',
                        width:100,
                        align: 'center',
                        tooltip:true,
                        key: 'belongOrgName'
                    },
                    {
                        title: '安装位置',
                        width:200,
                        align: 'center',
                        key: 'coordSite'
                    },
                    {
                        title: '使用状况',
                        width:200,
                        align: 'center',
                        key: 'useStatus'
                    },
                    {
                        title: '备注',
                        width:200,
                        align: 'center',
                        key: 'notes'
                    },
                    {
                        title: '操作',
                        key: 'action',
                        fixed: 'right',
                        width: 200,
                        align: 'center',
                        render: (h, params) => {
                            return h('div', [
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px'
                                    },
                                    on: {
                                        click: () => {
                                            this.showdata1(params,1);
                                        }
                                    }
                                }, '详情'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.createUserId == sessionStorage('userId').getObject('userId').userId ||  this.Common.userIdList.includes(sessionStorage('userId').getObject('userId').userId )||sessionStorage('userId').getObject('userId').userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined
                                        ||sessionStorage('userId').getObject('userId').userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined? '':'#d0d0d0' ,
                                        pointerEvents: params.row.createUserId == sessionStorage('userId').getObject('userId').userId ||  this.Common.userIdList.includes(sessionStorage('userId').getObject('userId').userId ) ||sessionStorage('userId').getObject('userId').userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined
                                        ||sessionStorage('userId').getObject('userId').userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                             this.showdata1(params,2);
                                        }
                                    }
                                }, '修改'),
                                h('Divider', {
                                    props: {
                                        type: 'vertical',
                                    }
                                }, ''),
                                h('A', {
                                    props: {
                                        type: 'primary',
                                        size: 'small'
                                    },
                                    style: {
                                        fontSize: '14px',
                                        color: params.row.createUserId == sessionStorage('userId').getObject('userId').userId ||  this.Common.userIdList.includes(sessionStorage('userId').getObject('userId').userId ) ||sessionStorage('userId').getObject('userId').userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined
                                        ||sessionStorage('userId').getObject('userId').userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined? 'red':'#d0d0d0' ,
                                        pointerEvents: params.row.createUserId == sessionStorage('userId').getObject('userId').userId ||  this.Common.userIdList.includes(sessionStorage('userId').getObject('userId').userId )||sessionStorage('userId').getObject('userId').userRole.find(obj => obj.roleId == '73b38b37dff64392ba0ee7dd579bf293') != undefined
                                        ||sessionStorage('userId').getObject('userId').userBeHandedOver.find(obj => obj == params.row.createUserId) != undefined? '' : 'none'
                                    },
                                    on: {
                                        click: () => {
                                            this.deleteData(params);
                                        }
                                    }
                                }, '删除')
                            ]);
                        }
                    }
				],
                showData: {},
                model1: false,
                buttonLoading: false,model2: false,
                select: {},
                eqCode: '',
                eqCName: '',
                showOrg: true,
                belongOrgIdQuery: '',
                belongOrgNameQuery: '',
                belongOrgId:'',
                belongOrgName: '',
                resultData: [],
                deleteRows:[],
                ruleValidate: {
                    eqCName: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    specId: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    makeOrgName: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    inspectionPeriod: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    productCertificateNo: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    useLicenseNo: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    registrationCertificateNo: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    commissionDate: [
                    {  message: " ",
                    validator: (rule, value, callback) => {
                            if (value == null || value == '' || value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'blur'
                    }
                    ],
                    fixedInspectionDate: [
                    {   message: " ",
                        validator: (rule, value, callback) => {
                            if (value == null || value == '' || value == undefined) {
                                callback(' ')
                            } else {
                                callback()
                            }
                        },
                        required: true,
                        trigger: 'blur'
                    }
                    ],
                    inspectionResult: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    belongOrgId: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    coordSite: [
                    { required: true, message: " ", trigger: "blur" }
                    ],
                    useStatus: [
                    { required: true, message: "  ", trigger: "blur" }
                    ]
                }
            }
        },
        watch:{
            "model1":function(qw,er){
                if(qw && this.model1){
                    setTimeout(()=>{
                        this.$refs.orgInfo.setCurrentOrg();
                    },100)
                }else{
                    this.$refs.orgInfo.setCurrentOrg();
                }
            },
            belongOrgId(val){
                setTimeout(()=>{
                    this.$refs.orgInfo.setCurrentOrg();
                },100);
            },
            belongOrgIdQuery(val){
                setTimeout(()=>{
                    this.$refs.orgInfoQuery.setCurrentOrg();
                },100);
            }
        },
        mounted: function() {
            this.tableHeight = window.innerHeight - this.$refs.table.$el.offsetTop - 145;
            this.$http.get(Api.queryGeneras).then((res) => {
                this.generaIds = res.data.data;
            })
            this.$http.get(Api.queryCategorys).then((res) => {
                this.categoryIds = res.data.data;
            })
            this.$http.get(Api.querySpecModels).then((res) => {
                this.specIds = res.data.data;
            })
            this.$http.get(Api.queryFactorys).then((res) => {
                this.factoryIds = res.data.data;
            })
            this.getInfo();
            this.selectCodingSort();
        },
        methods: {
            switchQuery(flag){
                this.switchFlag = flag;
                if(!this.switchFlag){
                    this.tableHeight = window.innerHeight - 220;
                }else{
                    this.tableHeight = window.innerHeight - 220;
                }
            },
            setBelongOrgIdQuery(data){
                this.belongOrgIdQuery = data[data.length - 1];
            },
            setBelongOrgNameQuery(data){
                this.belongOrgNameQuery = data;
            },
            setBelongOrgId(data){
                this.formCustom.belongOrgId = data[data.length - 1];
            },
            setBelongOrgName(data){
                this.formCustom.belongOrgName = data;
            },
            modalcancel() {
                this.formCustom = {};
                this.model1 = false;
            },
            addEquipment() {
                this.model1 = true;
                this.belongOrgId = ' ';
                this.belongOrgName = ' ';
                this.formCustom = {
                    eqId: '',
                    eqCName: '',
                    inspectionPeriod: '',
                    productCertificateNo: '',
                    useLicenseNo: '',
                    registrationCertificateNo: '',
                    commissionDate: '',
                    fixedInspectionDate: '',
                    inspectionResult: '',
                    belongOrgId: '',
                    inspectionPeriod: '',
                    useStatus: '',
                    notes: '',
                }
            },
            //重置输入框
            reset: function() {
                this.eqCode = '';
                this.eqCName = '';
                this.belongOrgIdQuery = '';
            },

            showdata1(data, flag) {
                this.belongOrgId = data.row.belongOrgId;
                this.belongOrgName = data.row.belongOrgName;
                if (flag == 1) {
                    //查看页面
                    this.showData = data.row;
                    this.model2 = true;
                } else {
                    //修改页面
                    this.formCustom = data.row;
                    this.formCustom.commissionDate = this.formatDate(new Date( this.formCustom.commissionDate), 'yyyy-MM-dd');
                    this.formCustom.fixedInspectionDate = this.formatDate(new Date( this.formCustom.fixedInspectionDate), 'yyyy-MM-dd');
                    this.model1 = true;
                }
            },

            getSelectRows (rows){
                this.deleteRows = rows;
            },
            batDelete(){
                let eqId = '';
                this.deleteRows.forEach(item=>{
                    eqId = eqId  + item.eqId + ","
                });
                eqId = eqId.substring(0, eqId.length - 1);
                this.$http.delete(Api.AssetAccountUrl + '/' + eqId).then((res) => {
                        if (res.data.status == 200) {
                            this.$Message.info('删除成功');
                            this.getInfo();
                        } else {
                            this.$Message.info('删除失败');
                        }
                    });
            },
            deleteData(params) {
                let istrue = confirm("是否确定删除?");
                if (istrue) {
                    this.$http.delete(Api.AssetAccountUrl + '/' + params.row.eqId).then((res) => {
                        if (res.data.status == 200) {
                            this.$Message.info('删除成功');
                            this.getInfo();
                        } else {
                            this.$Message.info('删除失败');
                        }
                    });
                }
            },
            submit() {
                this.$refs["formCustom"].validate((valid) => {
                    if (valid) { this.buttonLoading=true
                        this.formCustom.commissionDate = this.formatDate(new Date( this.formCustom.commissionDate), 'yyyy-MM-dd');
                        this.formCustom.fixedInspectionDate = this.formatDate(new Date( this.formCustom.fixedInspectionDate), 'yyyy-MM-dd');
                        if (this.formCustom.eqId == "") {
                            let userId = sessionStorage('userId').getObject('userId').userId;
                            let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
                            this.formCustom.createUserId = userId;
                            this.formCustom.createOrgId = orgId;
                                 this.$http.post(Api.AssetAccountUrl, this.formCustom).then((res) => {
                                if (res.data.status == 200) {
                                    this.getInfo();
                                    this.model1 = false;
                                    this.$Message.info('添加成功');
                                } else {
                                    this.$Message.info(res.data.message);
                                }
                                     this.buttonLoading=false
                                 }).catch(e => {
                                this.$Message.error("数据获取失败")
                                     this.buttonLoading=false
                                 });
                        } else {
                            let userId = sessionStorage('userId').getObject('userId').userId;
                            let orgId = sessionStorage('userId').getObject('userId').orgInfo.orgId;
                            this.formCustom.updateUserId = userId;
                            this.formCustom.updateOrgId = orgId;
                            this.$http.put(Api.AssetAccountUrl, this.formCustom).then((res) => {
                                if (res.data.status == 200) {
                                    this.getInfo();
                                    this.model1 = false;
                                    this.$Message.info('修改成功');
                                } else {
                                    this.$Message.info(res.data.message);
                                } this.buttonLoading=false
                            }).catch(e => {
                                this.$Message.error("数据获取失败")
                                this.buttonLoading=false
                            });
                        }
                    }
                });
            },
            // 查询编码大类列表
            getInfo: function() {this.loading = true ;
                if (this.eqCName == undefined) {
                    this.eqCName = "";
                }
                if (this.eqCode == undefined) {
                    this.eqCode = "";
                }
                if (this.belongOrgIdQuery == undefined) {
                    this.belongOrgIdQuery = "";
                }
                this.$http.get(Api.queryAccount + "?starPage=" + this.currentPage + "&size=" + this.pageSize
                     + "&eqCName=" + this.eqCName + "&belongOrgId=" + this.belongOrgIdQuery + "&orgId="+sessionStorage('userId').getObject('userId').companyId).then((res) => {
                    this.dataCount = res.data.data.totalSize; //总条数
                    this.resultData =  res.data.data.data; //查询到的所有编码
                    this.loading = false;
                })
            },
            handleCancel(){
                this.formCustom = {};
                this.model1 = false;
            },
            queryAccount() {
                this.dataCount = 0;
                this.currentPage = 1;
                this.getInfo();
            },
            changepage(pageIndex) {
                //当页码改变,选择获取当前页数,发送查询请求
                this.currentPage = pageIndex;
                this.getInfo();
            },
            nowPageSize(size) {
                this.pageSize = size;
                this.currentPage = 1;
                this.getInfo();
            },
            rowClassName(row, index) {
                return 'tdHeight';
            },
            formatDate(date, fmt) {
                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
                }
                let o = {
                    'M+': date.getMonth() + 1,
                    'd+': date.getDate(),
                    'h+': date.getHours(),
                    'm+': date.getMinutes(),
                    's+': date.getSeconds()
                };
                for (let k in o) {
                    if (new RegExp(`(${k})`).test(fmt)) {
                        let str = o[k] + '';
                        fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : this.padLeftZero(str));
                    }
                }
                return fmt;
            },
            padLeftZero(str) {
                return ('00' + str).substr(str.length);
            },
            selectCodingSort(){
                this.$http.get(Api.queryCodeDetailBySortId + '/IP-10001', {params: {}}).then((res) => {
                    this.inspectionPeriodList = res.data.data;
                });


            },
        },

    }
</script>


<style scoped lang="css">
    @import '../../../../index.css';
</style>
